const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const app = express();
app.use(cors())
// 转换 application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// 转换 application/json
app.use(bodyParser.json())

app.get('/', (req, res) => {
    res.send('Hello World!');
});

app.get('/getDateBase', (req, res) => {
    res.send({
        msg: '请求成功',
        data: [
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/08/2024082903121761-1024x576.jpg',
                type: '城市探索指南',
                text: '探寻五莲黄昏 | 金色余晖轻洒，温柔日照在光影中悄然绽放？',
                time: '17 小时前',
                eyes: '14,889',
                comment: '13',
                collect: '22'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/03/2024030708001722.jpg',
                type: '城市探索指南',
                text: '为什么美食家们评论最酷小首都惠灵顿是“全球美食储藏室”？',
                time: '15 小时前',
                eyes: '41,556',
                comment: '0',
                collect: '3'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091106340885-1024x576.jpg',
                type: '实用干货',
                text: '翠鸟枝头展翼，斑斓色彩如何演绎自然界的灵动与生机？',
                time: '1 天前',
                eyes: '3,234',
                comment: '13',
                collect: '56'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091107183769-1024x576.jpg',
                type: '城市探索指南',
                text: '新西兰如何以绝美景致与纯净生态，绘就自然天堂的梦幻蓝图？',
                time: '1 天前',
                eyes: '7,645',
                comment: '273',
                collect: '88'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091107165744-1024x576.jpg',
                type: '城市探索指南',
                text: '郁金香绚烂绽放，荷兰风车低语，这片花海如何不让人沉醉？',
                time: '1 天前',
                eyes: '3,346',
                comment: '456',
                collect: '58'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091106314334-1024x576.jpg',
                type: '城市探索指南',
                text: '宝藏旅行地推荐！秋色醉人，坝上竟是摄影师心中的金色圣地？',
                time: '1 天前',
                eyes: '355',
                comment: '133',
                collect: '567'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/01/2024011802360110.jpg',
                type: '城市探索指南',
                text: '在四季如春的最酷小首都惠灵顿徜徉，会遇到怎样的惊喜？',
                time: '1 天前',
                eyes: '2,314',
                comment: '32',
                collect: '32'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/06/2024060502375231.png',
                type: '城市探索指南',
                text: '为什么说最酷小首都惠灵顿是被低估了的“全球美食储藏室”？',
                time: '2 天前',
                eyes: '345',
                comment: '234',
                collect: '25'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091106314334-1024x576.jpg',
                type: '城市探索指南',
                text: '奥地利，如何以其古典韵味与现代创新，演绎欧陆风情新篇章？',
                time: '2 天前',
                eyes: '3,253',
                comment: '323',
                collect: '234'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091107155521-1024x576.jpg',
                type: '前沿资讯',
                text: '宝藏旅行地推荐！苏通大桥飞跨长江，展现现代工程奇迹之美！',
                time: '2 天前',
                eyes: '32',
                comment: '34',
                collect: '324'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091106273183-1024x576.jpg',
                type: '纪实·大美中国',
                text: '宝藏旅行地推荐！格聂神山之巅，究竟藏着怎样的绝世风光？',
                time: '3 天前',
                eyes: '3,453',
                comment: '32',
                collect: '7'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091106254024-1024x576.jpg',
                type: '城市探索指南',
                text: '恬静优雅的惠灵顿，究竟如何成为人人心中的天使之城？',
                time: '4 天前',
                eyes: '356',
                comment: '46',
                collect: '789'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/03/2024030707534521.jpg',
                type: '城市探索指南',
                text: '探秘苏格兰：古老城堡下，隐藏着哪些未解之谜与浪漫传说？',
                time: '5 天前',
                eyes: '7,654',
                comment: '679',
                collect: '676'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091105543991.jpg',
                type: '心灵驿站',
                text: '恰今日，平分秋色丨秋分时节大地如何绘就丰收与诗意的篇章？',
                time: '5 天前',
                eyes: '245',
                comment: '457',
                collect: '86'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091107081463-1024x576.jpg',
                type: '前沿资讯',
                text: '一份来自雪域高原的邀请！青藏铁路引领你探索无尽风光之旅！',
                time: '6 天前',
                eyes: '783',
                comment: '23',
                collect: '5'
            },
            {
                img: 'https://cookiescdn.lenovo.com.cn/wp-content/uploads/2024/09/2024091106240698-1024x576.jpg',
                type: '城市探索指南',
                text: '汉堡在惠灵顿人手中竟可以制作成味蕾轰炸的美食享受！',
                time: '1 周前',
                eyes: '3,880',
                comment: '18',
                collect: '59'
            }
        ]
    });
})

app.post('/findUser', (req, res) => {
    console.log(req.body);
    
    // 将收到的数据返回回去
    res.send({
        msg: '请求成功',
        data: req.body
    });
})

app.listen(3000, () => {
    console.log('服务启动成功，运行地址：http://localhost:3000');
})